package no.ntnu.fp.handlers;

import no.ntnu.fp.handler.Handler;
import no.ntnu.fp.messages.Message;
import no.ntnu.fp.messages.impl.AppointmentDeletedMessage;
import no.ntnu.fp.model.Appointment;
import no.ntnu.fp.model.CalendarModel;
import no.ntnu.fp.model.Employee;

public class AppointmentDeletedHandler implements Handler {

	private final CalendarModel calendarModel;
	
	public AppointmentDeletedHandler(CalendarModel calendarModel) {
		this.calendarModel = calendarModel;
	}

	@Override
	public void handleMessage(Message message) {
		AppointmentDeletedMessage appointmentDeletedMessage 
					= (AppointmentDeletedMessage) message;

		Appointment appointment = appointmentDeletedMessage.getAppointment();
		Employee emp = appointment.getEmployee();
		
		calendarModel.deleteAppointment(emp, appointment);
	}

}
